package com.dd.cloud.common.vo;

import com.dd.cloud.common.enums.ExceptionEnumInterface;
import com.dd.cloud.common.enums.ZkResponseEnum;
import com.dd.cloud.common.exception.ZekeAuthException;
import lombok.Data;

/**
 * @author zk
 */
@Data
public class ZekeResponse<T> {
    /**
     * 状态码
     */
    private Integer code;
    /**
     * 主体信息
     */
    private T body;

    private String message;

    public ZekeResponse(Integer code, T body) {
        this.code = code;
        this.body = body;
    }

    public ZekeResponse() {
        this.code = ZkResponseEnum.SUCCESS.getCode();
        this.body = null;
    }

    public ZekeResponse(T body) {
        this.code = ZkResponseEnum.SUCCESS.getCode();
        this.body = body;
    }

    public ZekeResponse(ZekeAuthException apiException) {
        this.code = apiException.getStatus();
        this.message = apiException.getMsg();
    }

    public ZekeResponse(ZkResponseEnum responseEnum) {
        this.code = responseEnum.getCode();
        this.message = responseEnum.getBody();
    }


    public ZekeResponse(ExceptionEnumInterface enumInterface) {
        this.code = enumInterface.getMessage().getCode();
        this.message = enumInterface.getMessage().getMsg();
    }
}
